/* In the following example queries the dimension information. */
#include <stdio.h>
#include <uf.h>
#include <uf_assem.h>
#include <uf_defs.h>
#include <uf_drf.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_part.h>
void ufusr(char *param, int *retcod, int param_len)
{
    char                          error_message[133] = "";
    int                           ifail = 0;
    tag_t                         dim_tag = NULL_TAG;
    int                           dim_type;
    double                        dim_origin[ 3 ];
    UF_DRF_dim_info_t             *dim_info;
//	UF_DRF_draft_aid_text_info_t  *text_info;
//	int                          num_text ,  num_lines;
	  FILE                  *file1;
    /* Initialize UG/Open API. */
    ifail = UF_initialize();
    /* Retrieve a dimension type */
    ifail = UF_OBJ_cycle_objs_in_part( UF_ASSEM_ask_work_part(),UF_dimension_type,
                                       &dim_tag );
	 file1 = fopen("5521_bef.dat","w+");
    /* Retrieve dimension information */
    while( !ifail && dim_tag )
    {
        {
            ifail = UF_DRF_ask_dim_info ( dim_tag, &dim_type,
                                          &dim_origin[ 0 ],
                                          &dim_info );
			
			fprintf(file1,"dim_tag=%d,  dim_type = %d \n"  , dim_tag,dim_type );
			fprintf(file1,"dim_origin[ 0 ]=%f,  dim_origin[ 1 ] = %f, dim_origin[ 2 ] = %f \n"  , 
				dim_origin[ 0 ],dim_origin[ 1 ],dim_origin[ 2 ] );
			fprintf(file1,"dim_info.num_lines=%d,  dim_info.num_test=%d\n"  , dim_info->num_lines,dim_info->num_text );
	         fprintf(file1,"dimation_value=%s,  \n"  , dim_info->text_info->text->string );
			 fprintf(file1,"d  \n"   );
            /* Free the dimension information memory */
            if( !ifail )
                UF_DRF_free_dimension( &dim_info );
        }
        /* Retrieve a dimension type */
        ifail = UF_OBJ_cycle_objs_in_part(
                                     UF_ASSEM_ask_work_part(),
                                     UF_dimension_type,
                                     &dim_tag );
    }
    printf( "UF_DRF_ask_dim_info sample " );
    if( ifail )
    {
        ifail = UF_get_fail_message( ifail, error_message );
        printf( "fails.\nError is: %s\n", error_message );
    }
    else
        printf( "is successful.\n" );
  UF_terminate();
  fclose(file1);
}


